<!DOCTYPE html>
<html>
<head><meta name="generator" content="Hexo 3.9.0">
    

    

    



    <meta charset="utf-8">
    
    
    
    <title>瓦片请求原理 | 奔跑的蜗牛 | 虚心若愚</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    
    <meta name="theme-color" content="#3F51B5">
    
    
    <meta name="keywords" content="gis,切片">
    <meta name="description" content="瓦片请求原理影像金字塔 原始单张图标比较大，客户端请求时间长，渲染速度慢，或者渲染不了这么大的图像。 对不同分辨率的图像进行切片缓存，提高访问速度。  原理如下：                                                                                              tileMatrix">
<meta name="keywords" content="gis,切片">
<meta property="og:type" content="article">
<meta property="og:title" content="瓦片请求原理">
<meta property="og:url" content="http://windynature.oschina.io/2020/03/17/gis基本原理/瓦片请求原理/index.html">
<meta property="og:site_name" content="奔跑的蜗牛">
<meta property="og:description" content="瓦片请求原理影像金字塔 原始单张图标比较大，客户端请求时间长，渲染速度慢，或者渲染不了这么大的图像。 对不同分辨率的图像进行切片缓存，提高访问速度。  原理如下：                                                                                              tileMatrix">
<meta property="og:locale" content="zh-CN">
<meta property="og:image" content="http://windynature.oschina.io/blog/2020/03/17/gis基本原理/瓦片请求原理/tileMatrix.png">
<meta property="og:image" content="http://windynature.oschina.io/blog/2020/03/17/gis基本原理/瓦片请求原理/tile.png">
<meta property="og:image" content="http://windynature.oschina.io/blog/2020/03/17/gis基本原理/瓦片请求原理/flowchart.png">
<meta property="og:updated_time" content="2020-03-18T04:05:29.308Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="瓦片请求原理">
<meta name="twitter:description" content="瓦片请求原理影像金字塔 原始单张图标比较大，客户端请求时间长，渲染速度慢，或者渲染不了这么大的图像。 对不同分辨率的图像进行切片缓存，提高访问速度。  原理如下：                                                                                              tileMatrix">
<meta name="twitter:image" content="http://windynature.oschina.io/blog/2020/03/17/gis基本原理/瓦片请求原理/tileMatrix.png">
    
        <link rel="alternative" href="/atom.xml" title="奔跑的蜗牛" type="application/atom+xml">
    
    <link rel="shortcut icon" href="/blog/favicon.ico">
    <link rel="stylesheet" href="//unpkg.com/hexo-theme-material-indigo@1.5.2/css/style.css">
    <script>window.lazyScripts=[]</script>
</head>

<body>
    <div id="loading" class="active"></div>

    <aside id="menu" class="hide" >
  <div class="inner flex-row-vertical">
    <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="menu-off">
        <i class="icon icon-lg icon-close"></i>
    </a>
    <div class="brand-wrap" style="background-image:url(/blog/img/timg.jpg)">
      <div class="brand">
        <a href="/blog/" class="avatar waves-effect waves-circle waves-light">
          <img src="/blog/img/user2.jpg">
        </a>
        <hgroup class="introduce">
          <h5 class="nickname">windy</h5>
          <a href="mailto:windynature@163.com" title="windynature@163.com" class="mail">windynature@163.com</a>
        </hgroup>
      </div>
    </div>
    <div class="scroll-wrap flex-col">
      <ul class="nav">
        
            <li class="waves-block waves-effect">
              <a href="/blog/"  >
                <i class="icon icon-lg icon-home"></i>
                主页
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="/blog/archives"  >
                <i class="icon icon-lg icon-archives"></i>
                归档
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="/blog/tags"  >
                <i class="icon icon-lg icon-tags"></i>
                标签
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="/blog/categories"  >
                <i class="icon icon-lg icon-th-list"></i>
                分类
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="https://github.com/WindyNature" target="_blank" >
                <i class="icon icon-lg icon-github"></i>
                Github
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="https://git.oschina.net/windynature" target="_blank" >
                <i class="icon icon-lg icon-mayun"></i>
                码云
              </a>
            </li>
        
      </ul>
    </div>
  </div>
</aside>

    <main id="main">
        <header class="top-header" id="header">
    <div class="flex-row">
        <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light on" id="menu-toggle">
          <i class="icon icon-lg icon-navicon"></i>
        </a>
        <div class="flex-col header-title ellipsis">瓦片请求原理</div>
        
        <div class="search-wrap" id="search-wrap">
            <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="back">
                <i class="icon icon-lg icon-chevron-left"></i>
            </a>
            <input type="text" id="key" class="search-input" autocomplete="off" placeholder="输入感兴趣的关键字">
            <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="search">
                <i class="icon icon-lg icon-search"></i>
            </a>
        </div>
        
        
        <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="menuShare">
            <i class="icon icon-lg icon-share-alt"></i>
        </a>
        
    </div>
</header>
<header class="content-header post-header">

    <div class="container fade-scale">
        <h1 class="title">瓦片请求原理</h1>
        <h5 class="subtitle">
            
                <time datetime="2020-03-17T15:37:55.660Z" itemprop="datePublished" class="page-time">
  2020-03-17
</time>


	<ul class="article-category-list"><li class="article-category-list-item"><a class="article-category-list-link" href="/blog/categories/GIS基本原理/">GIS基本原理</a></li></ul>

            
        </h5>
    </div>

    

</header>


<div class="container body-wrap">
    
    <aside class="post-widget">
        <nav class="post-toc-wrap" id="post-toc">
            <h4>TOC</h4>
            <ol class="post-toc"><li class="post-toc-item post-toc-level-2"><a class="post-toc-link" href="#瓦片请求原理"><span class="post-toc-text">瓦片请求原理</span></a><ol class="post-toc-child"><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#影像金字塔"><span class="post-toc-text">影像金字塔</span></a></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#地图分辨率换算原理"><span class="post-toc-text">地图分辨率换算原理</span></a><ol class="post-toc-child"><li class="post-toc-item post-toc-level-4"><a class="post-toc-link" href="#分辨率"><span class="post-toc-text">分辨率</span></a></li><li class="post-toc-item post-toc-level-4"><a class="post-toc-link" href="#比例尺"><span class="post-toc-text">比例尺</span></a></li><li class="post-toc-item post-toc-level-4"><a class="post-toc-link" href="#DPI-dot-per-inch"><span class="post-toc-text">DPI (dot per inch)</span></a></li><li class="post-toc-item post-toc-level-4"><a class="post-toc-link" href="#换算"><span class="post-toc-text">换算</span></a></li></ol></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#瓦片行列号换算原理"><span class="post-toc-text">瓦片行列号换算原理</span></a></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#获取瓦片的换算流程"><span class="post-toc-text">获取瓦片的换算流程</span></a><ol class="post-toc-child"><li class="post-toc-item post-toc-level-4"><a class="post-toc-link" href="#原理"><span class="post-toc-text">原理</span></a></li></ol></li></ol></li></ol>
        </nav>
    </aside>
    
<article id="post-gis基本原理/瓦片请求原理"
  class="post-article article-type-post fade" itemprop="blogPost">

    <div class="post-card">
        <h1 class="post-card-title">瓦片请求原理</h1>
        <div class="post-meta">
            <time class="post-time" title="2020年03月17日 23:37" datetime="2020-03-17T15:37:55.660Z"  itemprop="datePublished">2020-03-17</time>

            
	<ul class="article-category-list"><li class="article-category-list-item"><a class="article-category-list-link" href="/blog/categories/GIS基本原理/">GIS基本原理</a></li></ul>



            
<span id="busuanzi_container_page_pv" title="文章总阅读量" style='display:none'>
    <i class="icon icon-eye icon-pr"></i><span id="busuanzi_value_page_pv"></span>
</span>


            

        </div>
        <div class="post-content" id="post-content" itemprop="postContent">
            <h2 id="瓦片请求原理"><a href="#瓦片请求原理" class="headerlink" title="瓦片请求原理"></a>瓦片请求原理</h2><h3 id="影像金字塔"><a href="#影像金字塔" class="headerlink" title="影像金字塔"></a>影像金字塔</h3><ol>
<li>原始单张图标比较大，客户端请求时间长，渲染速度慢，或者渲染不了这么大的图像。</li>
<li>对不同分辨率的图像进行切片缓存，提高访问速度。</li>
</ol>
<p><strong>原理如下：</strong></p>
<figure class="image-bubble">
                <div class="img-lightbox">
                    <div class="overlay"></div>
                    <img src="/blog/2020/03/17/gis基本原理/瓦片请求原理/tileMatrix.png" alt="tileMatrix" title>
                </div>
                <div class="image-caption">tileMatrix</div>
            </figure>

<h3 id="地图分辨率换算原理"><a href="#地图分辨率换算原理" class="headerlink" title="地图分辨率换算原理"></a>地图分辨率换算原理</h3><h4 id="分辨率"><a href="#分辨率" class="headerlink" title="分辨率"></a>分辨率</h4><ol>
<li>地图距离代表的实际距离是多少</li>
</ol>
<h4 id="比例尺"><a href="#比例尺" class="headerlink" title="比例尺"></a>比例尺</h4><p>地图距离/实际距离</p>
<h4 id="DPI-dot-per-inch"><a href="#DPI-dot-per-inch" class="headerlink" title="DPI (dot per inch)"></a>DPI (dot per inch)</h4><p>每英寸有多少个像素点</p>
<h4 id="换算"><a href="#换算" class="headerlink" title="换算"></a>换算</h4><ul>
<li><p>1英寸 = 2.54 厘米</p>
</li>
<li><p>1英寸 = 96像素</p>
</li>
<li><p>1像素 = 0.0254 / 96  米  </p>
<p><strong>resolution=scale*inch2centimeter/dpi</strong>。</p>
<p>其中<code>scale</code>是地图比例尺，<code>inch2centimeter</code>为英寸转厘米的参数，<code>dpi</code>为1英寸所包含的像素。</p>
</li>
</ul>
<p>  示例：     则根据1：125000000比例尺，图上1像素代表实地距离是 125000000*0.0254/96 = 33072.9166666667米，则该比例尺的分辨率为33072.9166666667米。</p>
<blockquote>
<p>注意：</p>
<ol>
<li><p>其他坐标系可根据实际地图单位进行替换</p>
</li>
<li><p>对于 WMTS 1.0.0 标准服务来说，其分辨率是通过像元大小（0.28mm=0.00028m）来界定的，转换为屏幕分辨率，即每英寸像元数为：1inch/(0.00028m/0.0254(m/inch))=0.0254/0.00028≈90.714。</p>
</li>
</ol>
</blockquote>
<h3 id="瓦片行列号换算原理"><a href="#瓦片行列号换算原理" class="headerlink" title="瓦片行列号换算原理"></a>瓦片行列号换算原理</h3><p>基本上所有的地图引擎访问地图服务都是通过切片的方式访问。地图引擎获取当前比例尺，然后获取屏幕的可视区域，通过可视区范围向地图服务器发送请求获取该可视区域的切片，然后拼接成为一副地图。前端的展示也多种多样，根据web技术的发展，主要有img标签，svg，canvas以及webgl。</p>
<p>假设，地图切图的原点是（x0,y0），地图的瓦片大小是tileSize，地图屏幕上1像素代表的实际距离是<code>resolution</code>。计算坐标点（x,y）所在的瓦片的行列号的公式是：</p>
<p><code>col  = floor((x0 - x)/( tileSize*resolution))</code></p>
<p><code>row = floor((y0 - y)/( tileSize*resolution))</code></p>
<p>这个公式应该不难理解，简单点说就是，首先算出一个瓦片所包含的实际长度是多少LtileSize，然后再算出此时屏幕上的地理坐标点离瓦片切图的起始点间的实际距离LrealSize，然后用实际距离除以一个瓦片的实际长度，即可得此时的瓦片行列号：LrealSize/LtileSize。</p>
<figure class="image-bubble">
                <div class="img-lightbox">
                    <div class="overlay"></div>
                    <img src="/blog/2020/03/17/gis基本原理/瓦片请求原理/tile.png" alt="tile" title>
                </div>
                <div class="image-caption">tile</div>
            </figure>

<h3 id="获取瓦片的换算流程"><a href="#获取瓦片的换算流程" class="headerlink" title="获取瓦片的换算流程"></a>获取瓦片的换算流程</h3><h4 id="原理"><a href="#原理" class="headerlink" title="原理"></a>原理</h4><p>（1）得到画布的高度和宽度以及此时需要显示的地图的几何范围</p>
<p>（2）得到画布的高度和宽度以及此时需要显示的地图的几何范围，同时也得到了需要显示的地图的级别</p>
<p>最后，我们需要得到在这两种需求下的瓦片行列号范围。</p>
<figure class="image-bubble">
                <div class="img-lightbox">
                    <div class="overlay"></div>
                    <img src="/blog/2020/03/17/gis基本原理/瓦片请求原理/flowchart.png" alt="flowchart" title>
                </div>
                <div class="image-caption">flowchart</div>
            </figure>
        </div>

        <blockquote class="post-copyright">
    <div class="content">
        
<span class="post-time">
    最后更新时间：<time datetime="2020-03-18T04:05:29.308Z" itemprop="dateUpdated">2020年3月18日 12:05</time>
</span><br>


        这里写留言或版权声明：<a href="/blog/2020/03/17/gis基本原理/瓦片请求原理/" target="_blank" rel="external">http://windynature.oschina.io/2020/03/17/gis基本原理/瓦片请求原理/</a>
    </div>
    <footer>
        <a href="http://windynature.oschina.io">
            <img src="/blog/img/user2.jpg" alt="windy">
            windy
        </a>
    </footer>
</blockquote>

        


        <div class="post-footer">
            
	<ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/blog/tags/gis/">gis</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/blog/tags/切片/">切片</a></li></ul>


            
<div class="page-share-wrap">
    

<div class="page-share" id="pageShare">
    <ul class="reset share-icons">
      <li>
        <a class="weibo share-sns" target="_blank" href="http://service.weibo.com/share/share.php?url=http://windynature.oschina.io/2020/03/17/gis基本原理/瓦片请求原理/&title=《瓦片请求原理》 — 奔跑的蜗牛&pic=http://windynature.oschina.io/img/user2.jpg" data-title="微博">
          <i class="icon icon-weibo"></i>
        </a>
      </li>
      <li>
        <a class="weixin share-sns wxFab" href="javascript:;" data-title="微信">
          <i class="icon icon-weixin"></i>
        </a>
      </li>
      <li>
        <a class="qq share-sns" target="_blank" href="http://connect.qq.com/widget/shareqq/index.html?url=http://windynature.oschina.io/2020/03/17/gis基本原理/瓦片请求原理/&title=《瓦片请求原理》 — 奔跑的蜗牛&source=" data-title=" QQ">
          <i class="icon icon-qq"></i>
        </a>
      </li>
      <li>
        <a class="facebook share-sns" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=http://windynature.oschina.io/2020/03/17/gis基本原理/瓦片请求原理/" data-title=" Facebook">
          <i class="icon icon-facebook"></i>
        </a>
      </li>
      <li>
        <a class="twitter share-sns" target="_blank" href="https://twitter.com/intent/tweet?text=《瓦片请求原理》 — 奔跑的蜗牛&url=http://windynature.oschina.io/2020/03/17/gis基本原理/瓦片请求原理/&via=http://windynature.oschina.io" data-title=" Twitter">
          <i class="icon icon-twitter"></i>
        </a>
      </li>
      <li>
        <a class="google share-sns" target="_blank" href="https://plus.google.com/share?url=http://windynature.oschina.io/2020/03/17/gis基本原理/瓦片请求原理/" data-title=" Google+">
          <i class="icon icon-google-plus"></i>
        </a>
      </li>
    </ul>
 </div>



    <a href="javascript:;" id="shareFab" class="page-share-fab waves-effect waves-circle">
        <i class="icon icon-share-alt icon-lg"></i>
    </a>
</div>



        </div>
    </div>

    
<nav class="post-nav flex-row flex-justify-between">
  
    <div class="waves-block waves-effect prev">
      <a href="/blog/2020/03/18/mapbox/mapbox源码分析/" id="post-prev" class="post-nav-link">
        <div class="tips"><i class="icon icon-angle-left icon-lg icon-pr"></i> Prev</div>
        <h4 class="title">mapbox源码分析（一）</h4>
      </a>
    </div>
  

  
    <div class="waves-block waves-effect next">
      <a href="/blog/2020/03/17/gis基本原理/计算不规则多边形的质心/" id="post-next" class="post-nav-link">
        <div class="tips">Next <i class="icon icon-angle-right icon-lg icon-pl"></i></div>
        <h4 class="title">计算不规则多边形的质心</h4>
      </a>
    </div>
  
</nav>



    

<div class="comments" id="comments">
    <div class="ds-thread" data-thread-key="gis基本原理/瓦片请求原理" data-title="瓦片请求原理" data-url="http://windynature.oschina.io/2020/03/17/gis基本原理/瓦片请求原理/"></div>
</div>
<script>
lazyScripts.push('//cdn.bootcss.com/marked/0.3.6/marked.min.js');

var duoshuoQuery = {short_name:'ysblog', theme: 'none'};
lazyScripts.push('//unpkg.com/hexo-theme-material-indigo@1.5.2/js/embed.min.js');


</script>










</article>



</div>

        <footer class="footer">
    <div class="top">
        
<p>
    <span id="busuanzi_container_site_uv" style='display:none'>
        站点总访客数：<span id="busuanzi_value_site_uv"></span>
    </span>
    <span id="busuanzi_container_site_pv" style='display:none'>
        站点总访问量：<span id="busuanzi_value_site_pv"></span>
    </span>
</p>


        <p>
            <span><a href="/atom.xml" target="_blank" class="rss" title="rss"><i class="icon icon-lg icon-rss"></i></a></span>
            <span>博客内容遵循 <a href="http://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">知识共享 署名 - 非商业性 - 相同方式共享 4.0协议</a></span>
        </p>
    </div>
    <div class="bottom">
        <p>
            <span>Power by <a href="http://hexo.io/" target="_blank">Hexo</a> Theme <a href="https://github.com/yscoder/hexo-theme-indigo" target="_blank">indigo</a></span>
            <span>奔跑的蜗牛 &copy; 2015 - 2020</span>
        </p>
    </div>
</footer>

    </main>
    <div class="mask" id="mask"></div>
<a href="javascript:;" id="gotop" class="waves-effect waves-circle waves-light"><span class="icon icon-lg icon-chevron-up"></span></a>



<div class="global-share" id="globalShare">
    <ul class="reset share-icons">
      <li>
        <a class="weibo share-sns" target="_blank" href="http://service.weibo.com/share/share.php?url=http://windynature.oschina.io/2020/03/17/gis基本原理/瓦片请求原理/&title=《瓦片请求原理》 — 奔跑的蜗牛&pic=http://windynature.oschina.io/img/user2.jpg" data-title="微博">
          <i class="icon icon-weibo"></i>
        </a>
      </li>
      <li>
        <a class="weixin share-sns wxFab" href="javascript:;" data-title="微信">
          <i class="icon icon-weixin"></i>
        </a>
      </li>
      <li>
        <a class="qq share-sns" target="_blank" href="http://connect.qq.com/widget/shareqq/index.html?url=http://windynature.oschina.io/2020/03/17/gis基本原理/瓦片请求原理/&title=《瓦片请求原理》 — 奔跑的蜗牛&source=" data-title=" QQ">
          <i class="icon icon-qq"></i>
        </a>
      </li>
      <li>
        <a class="facebook share-sns" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=http://windynature.oschina.io/2020/03/17/gis基本原理/瓦片请求原理/" data-title=" Facebook">
          <i class="icon icon-facebook"></i>
        </a>
      </li>
      <li>
        <a class="twitter share-sns" target="_blank" href="https://twitter.com/intent/tweet?text=《瓦片请求原理》 — 奔跑的蜗牛&url=http://windynature.oschina.io/2020/03/17/gis基本原理/瓦片请求原理/&via=http://windynature.oschina.io" data-title=" Twitter">
          <i class="icon icon-twitter"></i>
        </a>
      </li>
      <li>
        <a class="google share-sns" target="_blank" href="https://plus.google.com/share?url=http://windynature.oschina.io/2020/03/17/gis基本原理/瓦片请求原理/" data-title=" Google+">
          <i class="icon icon-google-plus"></i>
        </a>
      </li>
    </ul>
 </div>


<div class="page-modal wx-share" id="wxShare">
    <a class="close" href="javascript:;"><i class="icon icon-close"></i></a>
    <p>扫一扫，分享到微信</p>
    <img src="" alt="微信分享二维码">
</div>




    <script src="//cdn.bootcss.com/node-waves/0.7.4/waves.min.js"></script>
<script>
var BLOG = { ROOT: '/blog/', SHARE: true, REWARD: false };



</script>

<script src="//unpkg.com/hexo-theme-material-indigo@1.5.2/js/main.min.js"></script>


<div class="search-panel" id="search-panel">
    <ul class="search-result" id="search-result"></ul>
</div>
<template id="search-tpl">
<li class="item">
    <a href="{path}" class="waves-block waves-effect">
        <div class="title ellipsis" title="{title}">{title}</div>
        <div class="flex-row flex-middle">
            <div class="tags ellipsis">
                {tags}
            </div>
            <time class="flex-col time">{date}</time>
        </div>
    </a>
</li>
</template>

<script src="//unpkg.com/hexo-theme-material-indigo@1.5.2/js/search.min.js" async></script>






<script async src="//dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"></script>





</body>
</html>
